package com.ckk.springcloud.service.impl;

import com.ckk.springcloud.service.RabbitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import java.util.UUID;

/**
 * @author 陈昆昆
 * @version 1.0
 * @date 2020/6/16 23:39
 */
@EnableBinding(Source.class)//定义生产者发送消息管道
@Slf4j
public class RabbitServiceImpl implements RabbitService {
    @Autowired
    private MessageChannel output;

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();//准备消息内容
        output.send(MessageBuilder.withPayload(serial).build());
        log.info(serial+"***********************");
        return serial;
    }
}
